﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace EZBarTender_Wrapper.SqlExecutor
{
	public class MSSqlExecutor : SqlExecutorBase
	{
		public MSSqlExecutor(string connectionString) : base(connectionString) { }

		public override void GenerateStatements(string fileName)
		{
			try
			{
				using (StreamReader reader = new StreamReader(fileName))
				{
					string line = "";
					string statement = "";
					while ((line = reader.ReadLine()) != null)
					{
						if (line.StartsWith("GO"))
						{
							Statements.Add(statement);
							statement = "";
						}
						else
						{
							statement += Environment.NewLine + line;
						}
					}
				}
			}
			catch (IOException ex)
			{
				MessageBox.Show(ex.Message, "I/O Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				//Environment.Exit(1);
			}
		}
	}
}
